<template>
	<uni-nav-bar
		style="font-weight: bold"
		title="我的评测"
		:fixed="true"
		:statusBar="true"
		:border="false"
		leftWidth="200rpx"
		rightWidth="200rpx"
	>
		<template v-slot:left>
			<view style="height: 60rpx; width: 60rpx" @tap="nav_back">
				<image
					style="width: 100%; height: 100%"
					src="https://mcdn.chatgk.com/xcx/static/images/public/nav_back.png"
				></image>
			</view>
		</template>
	</uni-nav-bar>
	<view class="ping-view flex-column">
		<view class="ping-bg-view">
			<image
				class="ping-bg-img"
				mode="aspectFill"
				src="https://mcdn.chatgk.com/xcx/static/images/ping/ping_mian_bg.png"
			/>
		</view>
		<text v-if="dataList.length > 0" class="ping-user-text">{{ '我的评测(' + dataList.length + ')' }}</text>
		<view
			v-if="dataList.length > 0"
			class="ping-item-view flex-row"
			v-for="(item, index) in dataList"
			:key="index"
			@tap="tapPingResult(item)"
		>
			<view class="ping-item-view1 flex-column">
				<text class="ping-item-text1">专业定位评测</text>
				<text class="ping-item-text2">{{ item.date }}</text>
			</view>
			<image
				class="ping-mian-more-img"
				mode="aspectFill"
				src="https://mcdn.chatgk.com/xcx/static/images/ping/ping-mian-more-img.png"
			/>
		</view>
		<loading v-show="loadshow"></loading>
	</view>
</template>

<script>
import userManager from '@/common/manager/user-manager.js';

export default {
	data() {
		return {
			loadshow: false,
			dataList: []
		};
	},

	onLoad() {
		uni.$on('pingUpdate', this.pingUpdate);
		// this.dataList = userManager.getPingInfo();
		// this.getJudgeResInfo()
	},
	onShow() {
		this.getJudgeResInfo();
	},

	methods: {
		nav_back() {
			uni.navigateBack();
		},
		//查询测评信息
		getJudgeResInfo() {
			this.loadshow = true;
			this.$request.judgeResInfoAPI().then((res) => {
				this.loadshow = false;
				this.dataList = res.data;
			});
		},
		startPing() {
			if (this.$userManager.isLogin()) {
				// 填写信息
				const userInfo = getApp().globalData.userInfo;
				if (!userInfo.nick || !userInfo.pid || !userInfo.xk_type) {
					uni.navigateTo({
						url: '/subpackages/subpackage2/pages/login/perfect-info'
					});
					return;
				}

				uni.navigateTo({
					url: '/pages/tabBar/ping/ping-question'
				});
			}
		},

		pingUpdate() {
			setTimeout(() => {
				this.dataList = userManager.getPingInfo();
				// this.getJudgeResInfo()
			}, 150);
		},

		// tapPingResult(index) {
		//     const pingResult = this.dataList[index];
		//     uni.navigateTo({
		//         url: '/subpackages/subpackage1/pages/tabBar/ping/ping-result?uuid=' + pingResult.uuid
		//     });
		// },
		tapPingResult(index) {
			// const pingResult = this.dataList[index];
			uni.setStorageSync('pingbaogaoid', index.id);
			this.loadshow = true;
			this.$request
				.judgeResInfoAPI({
					id: index.id
				})
				.then((res) => {
					this.loadshow = false;
					uni.navigateTo({
						url:
							'/subpackages/subpackage1/pages/tabBar/ping/ping-result?isfrom=2&uuid=' +
							res.data.uuid +
							'&data=' +
							JSON.stringify(res.data) +
							'&id=' +
							index.id
					});
				});
		}
		// 删除指定
		// tapPingResult(index) {
		// 	this.$request.judgeResSaveAPI({
		// 		id: index.id,
		// 		operate: 'del'
		// 	}).then((res) => {

		// 	})
		// },
	}
};
</script>

<style>
/* page {
        background-color: #F8F8F8;
    } */

.ping-view {
	background-color: #0000;
	width: 100%;
	/* height: 100%; */
	/* padding: 60rpx 32rpx 0 32rpx; */
}

/* 背景 */
.ping-bg-view {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: -1;
}

.ping-bg-img {
	width: 100%;
	height: 100%;
}

/* 评测 */
.ping-mian-view {
	margin: 60rpx 32rpx 40rpx 32rpx;
	height: 360rpx;
}

.ping-mian-1-text {
	margin: 72rpx 0 0 72rpx;
	color: #fff;
	font-size: 32rpx;
	font-family: PingFangSC-Semibold;
	font-weight: 600;
}

.ping-mian-2-text {
	margin: 20rpx 0 0 72rpx;
	color: #fff;
	font-size: 24rpx;
	font-family: PingFangSC-Semibold;
	font-weight: 600;
}

.ping-mian-3-view {
	margin: 44rpx 0 0 72rpx;
	width: 172rpx;
	height: 60rpx;
	border-radius: 30rpx;
	justify-content: center;
	align-items: center;
	background-color: #fff;
}

.ping-mian-3-text {
	color: #464646;
	font-size: 24rpx;
	font-family: PingFangSC-Semibold;
	font-weight: 600;
}

/* item */
.ping-user-text {
	display: inline-block;
	margin: 24rpx 0rpx 20rpx 32rpx;
	color: #333333;
	font-size: 32rpx;
	font-weight: bold;
}

.ping-item-view {
	margin: 0rpx 32rpx 20rpx 32rpx;
	height: 134rpx;
	border-radius: 20rpx;
	display: flex;
	justify-content: space-between;
	align-items: center;
	background-color: #fff;
}

.ping-item-view1 {
	margin-left: 36rpx;
	display: flex;
	flex-direction: column;
}

.ping-item-text1 {
	color: #333333;
	font-size: 32rpx;
	font-weight: bold;
}

.ping-item-text2 {
	margin-top: 4rpx;
	color: #999999;
	font-size: 24rpx;
	font-weight: bold;
}

.ping-mian-more-img {
	margin-right: 32rpx;
	width: 16rpx;
	height: 24rpx;
}
</style>
